## Check if everything installed
required_packages <- c("CBPS", "scales", "estimatr", "tidyverse",
                       "gridExtra", "stargazer", "texreg", "xtable",
                       "lattice", "corrplot", "equivalence", "sp",
                       "spdep", "rgdal", "maps", "mapdata",
                       "maptools", "ggmap", "patchwork", "psych", "reshape2",
                       "knitr", "sandwich", "lmtest")

allpkgs <- installed.packages()
if(!all(required_packages %in% rownames(allpkgs))){
  not_installed <- required_packages[!(required_packages %in% rownames(allpkgs))]
  install.packages(not_installed)
}

